package max;
package max;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class Maximum {
        public static void main(String[] args) throws IOException {
        	try{
        BufferedReader in= null;
        PrintWriter out=null;
        
                if (args.length==0) {
                        out=new PrintWriter(new FileWriter("out.txt"));
                        in=new BufferedReader(new FileReader("in.txt"));
                        }else if(args.length<2){
                                System.out.println("File name error");
                        }
                        else{
                                in=new BufferedReader(new FileReader(args[0]+".txt"));
                                out=new PrintWriter(new FileWriter(args[1]+".txt"));
                        }

        String str;
        
        String[] arrayStr;
        int[] arrayInt;
        List<Integer> finalList = Collections.synchronizedList(new ArrayList<Integer>());

        ExecutorService executor = Executors.newFixedThreadPool(5);

        try {
        	int count = 0;
            while ((str = in.readLine()) != null) {
                count++;
                arrayStr = str.split(" ");

                arrayInt = new int[arrayStr.length];

                for (int i = 0; i < arrayStr.length; i++) {
                    arrayInt[i] = Integer.parseInt(arrayStr[i]);
                }
                
                
                Runnable thread = new Threads(arrayInt, finalList);
                executor.execute(thread);

            }
            executor.shutdown();

            while (!(executor.isTerminated())) {
            }

            int max = Integer.MIN_VALUE;

            for (int element : finalList) {
                if (element > max) {
                    max = element;
                }
            }

            out.write(Integer.toString(max));
        
        
        } catch (IOException e) {
            System.out.println("Error in reading file");
        }

        try {
            in.close();
        } catch (IOException e) {
            System.out.println("Error: Cannot close input buffer");
        }
        out.close();
        }catch (IOException e) {
                System.out.println("Error: Cannot close output buffer");
        }
        	
        }
}
        
        
        
	


 



   
